//创建线程的方法：1.创建子类，继承Thread，重写run，调用start   2.创建子类，实现Runnable接口，重写run，搭配Thread对象进行start
//2
class Myrunnable implements Runnable{
    @Override
    public void run() {
        while(true){
            System.out.println("hello Runnable Thread!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class Demo3 {
    public static void main(String[] args) throws InterruptedException {
        Runnable runnable=new Myrunnable();
        //runnable.start();
        //runnable没有start方法，想要启动线程，需要搭配Thread
        Thread thread=new Thread(runnable);
        thread.start();

        while(true){
            System.out.println("hello main!");
            Thread.sleep(1000);
        }
    }
}
